package com.consumer;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.logging.LogFile;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import com.constrant.RabbitMQConstant;
import com.constrant.SpringConstant;
import com.vo.ExampleEvent;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author: chenfangzhi
 * @Description:
 * @Date: 2018/9/23-19:18
 * @ModifiedBy:
 */
@Component
@Slf4j
@Profile(SpringConstant.DIRECT_LISTENER_PROFILE)
public class DirectConsumer {
	private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogFile.class);
    @RabbitListener(
        bindings = @QueueBinding(
            exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC,
                durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT),
            value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT,
                autoDelete = RabbitMQConstant.TURE_CONSTANT),
            key = RabbitMQConstant.DIRECT_KEY
        ),
        containerFactory = "directRabbitListenerContainerFactory"
    )
    public void process(ExampleEvent event) {
        log.info("direct container receive message:{} ", event);
    }

}
